package com.example.demo.controller;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RabbitMqController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @RequestMapping("/MEC2")
    public String mc2(){
        for(int i=0;i<10;i++) {
            rabbitTemplate.convertAndSend("MEC2", "test.bbb", "hello,"+i);
        }
        return "success";
    }

    @RequestMapping("/MEC1")
    public String mc1(){
        for(int i=0;i<10;i++) {
            rabbitTemplate.convertAndSend("MEC1", "test.bbb", "hello,mc1"+i);
        }
        return "success";
    }
}
